package cu.tedu._07springaop.egaop1;

import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.springframework.stereotype.Component;


@Aspect
@Component
public class OrderAspect {
    @Before(value = "execution(public void cu.tedu._07springaop.egaop1.OrderServiceImpl.*(..))")
    public void beforeMethod(JoinPoint joinPoint){
        int args = (int) joinPoint.getArgs()[0];
        if (args <=0) {
            throw new IllegalArgumentException("订单数量不能小于0");
        }
    }
}
